<template>
	<view class="content">
		<mvBar :mysNavConfig="mysNavConfig"></mvBar>
		<view class="itme-box">
			<u-toast ref="uToast"></u-toast>
			<view
				:class="['h-table',item.healthStatus=='2' ? 'h-table-warning' : item.healthStatus==3? 'h-table-danger' : 'h-table-success']"
				v-for="(item,index) in abnormalList" :key="item.abnormalRealId">
				<view class="h-tr h-tr-2" @click="record(item)">
					<view class="h-td h-td-colspan h-td-rowspan">
						<view class="h-tr h-tr-1 h-thead">
							<view class="h-td">{{item.collectedTime}} {{item.equipmentName}} - {{item.pointName}}</view>
						</view>
						<view class="h-tr h-tr-1 ">
							<view class="h-td">{{item.description}} </view>
						</view>
						<view class="h-tr h-tr-2">
							<view class="h-td">{{item.featureName}}</view>
							<view class="h-td">{{item.value}}</view>
						</view>
					</view>
				</view>
			</view>
			<u-loadmore :status="loadStatus" :loading-text="loadingText" :loadmore-text="loadmoreText"
				:nomore-text="nomoreText" bgColor="#f2f2f2"></u-loadmore>
		</view>
	</view>
</template>


<script>
	export default {
		data() {
			return {
				mysNavConfig: {
					/* 占位开启  */
					navPadding: true,
					/* 背景 */
					bgColor: "#0055ff",
					isHome: true,
					/* 标题 （屏幕中心居中 两边图标中心居中使用slot center1） */
					navTitle: {
						text: "报警信息",
						color: "#ffffff",
						fontSize: "20px", // px upx rpx
						fontWeight: "500", // 100 - 700
					}
				},
				userInfo: '',
				abnormalList: [],
				loadStatus: 'loadmore',
				pageIndex: 1,
				pageSize: 10,
				loadingText: '加载中...',
				loadmoreText: '上拉加载更多',
				nomoreText: '无数据'
			}
		},
		onLoad(option) {
			this.userInfo = uni.getStorageSync('userInfo');

		},
		onShow() {
			this.abnormalList = [];
			this.pageIndex = 1;
			this.getAbnormalList(this.pageIndex);
		},
		methods: {
			//跳转到记录列表
			record(item) {
				uni.navigateTo({
					url: '/pages/records/recordList?pointRealId=' + item.pointRealId + "&equipmentRealId=" + item
						.equipmentRealId
				})
			},
			onReachBottom() {
				this.loadStatus = "loading";
				setTimeout(() => {
					this.pageIndex++;
					this.getAbnormalList(this.pageIndex);
				}, 1000);
			},
			getAbnormalList(pageIndex) {
				uni.request({
					url: getApp().globalData.serverAddress + this.$uri.Uri_getAbnormalList.replace('{userRealId}',
						this.userInfo.userRealId),
					dataType: "json",
					method: "GET",
					data: {
						page: pageIndex,
						limit: this.pageSize
					},
					success: (res) => {
						console.log(res);
						if (res.data.count > 0) {
							for (let i = 0; i < res.data.count; i++) {
								this.abnormalList.push(res.data.data[i]);
							}
							this.loadStatus = "loadmore";
						} else {
							this.loadStatus = "nomore";
						}
					}
				})
			}
		},
		onPullDownRefresh() {
			this.abnormalList = [];
			this.pageIndex = 1;
			this.getAbnormalList(this.pageIndex);
			uni.stopPullDownRefresh();
		}
	}
</script>

<style lang="scss">
	/* 引入表格样式表 */
	@import "../../common/helang-table.scss";


	/* 示例样式开始 */
	.content {
		font-size: 28rpx;
		background-color: #f3f3f3;

		.red {
			background-color: #DD524D;
			color: #fff;
			text-align: center;
		}

		.green {
			background-color: #42b983;
			color: #fff;
			text-align: center;
		}

		.blue {
			background-color: #007AFF;
			color: #fff;
			text-align: center;
		}

		.yellow {
			background-color: #ffaa00;
			color: #fff;
			text-align: center;
		}

		.listenText {
			color: #007AFF;
			font-size: 16px;
		}

		.itme-box {
			padding: 20rpx;
			background-color: #fff;
			margin-bottom: 20rpx;

			.title {
				padding-bottom: 20rpx;
				margin-bottom: 20rpx;
				border-bottom: #e5e5e5 solid 1px;
				line-height: normal;
			}

			.width-fill {
				width: 100%;
			}

			.preview-box {
				height: 400rpx;
				box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
			}
		}
	}

	/* 示例样式结束 */
</style>
